package com.flyee.viewer.ui.realty.solidhouseshow
{
	import com.flyee.utils.Constants;
	import com.flyee.utils.load.StackLoader;
	import com.flyee.utils.load.model.LoaderModel;
	import com.flyee.utils.load.processor.LoadLevelType;
	import com.flyee.utils.load.processor.LoadReturnType;
	
	import flash.events.ProgressEvent;
	
	import mx.containers.Canvas;
	import mx.controls.ProgressBar;
	import mx.core.UIComponent;
	import mx.managers.PopUpManager;
	
	public class ShowSolidHouse extends Canvas
	{
		private var returnFun:Function = null;
		private var progressWindow:ProgressBar = null;
		private var myLoader:LoaderModel = null;
		public function ShowSolidHouse(tagURL:String,returnFun:Function)
		{
			tagURL = Constants.STATIC_SERVER + "/" + tagURL;
			this.returnFun = returnFun;
			showPic(tagURL);
			
		}
		private function showPic(url:String):void
		{
			var tempLoader:StackLoader = new StackLoader();
			tempLoader.load(url,LoadLevelType.LV_1,this.progressHandle,this.getLoader,
							LoadReturnType.RETURN_LOADER,null);
		} 
		private function progressHandle(e:ProgressEvent):void
		{
			if(this.progressWindow == null)
			{
				this.progressWindow = new ProgressBar();
				PopUpManager.addPopUp(this.progressWindow,this.parent);
				PopUpManager.centerPopUp(this.progressWindow)
			}
			this.progressWindow.label = "加载立体户型资源" + Math.round(e.bytesLoaded/e.bytesTotal*100)+"%";
		}
			
		private function getLoader(tagContainer:LoaderModel):void
		{
			PopUpManager.removePopUp(this.progressWindow);
			this.progressWindow = null;
			this.myLoader = tagContainer
			var tempUI:UIComponent = new UIComponent();
			tempUI.addChild(this.myLoader);
			this.addChild(tempUI);
			//this.returnFun();
		}
		public function clear():void
		{
			this.removeAllChildren();
			this.myLoader.unload();
			this.myLoader.clear();
			this.myLoader = null;
			this.progressWindow = null;
		}
	}
}